/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ListenerCreatorPane.java
 *
 * Created on 15.3.2011, 16:32:45
 */
package cz.muni.fi.rum.gui.component;

import cz.muni.fi.rum.domainmodel.ReflectorListener;
import cz.muni.fi.rum.domainmodel.ReflectorListener.ReflectorListenerType;
import cz.muni.fi.rum.domainmodel.ReflectorSession;
import cz.muni.fi.rum.gui.FieldValidator;
import cz.muni.fi.rum.gui.MainFrame;
import cz.muni.fi.rum.gui.MyDoggyController;
import cz.muni.fi.rum.sender.Factory;
import cz.muni.fi.rum.sender.SenderException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.application.Action;
import org.noos.xing.mydoggy.Content;
import org.noos.xing.mydoggy.ToolWindowManager;

/**
 *
 * @author pmikulasek
 */
public class ListenerCreatorPane extends javax.swing.JPanel implements SaveAble {

    //private Reflector reflector;
    //private final Long listenerId;
    private final ReflectorListener reflectorListener;
    private final ToolWindowManager wm;
    private final ListenerNode node;

    /** Creates new form ListenerCreatorPane */
    public ListenerCreatorPane(ListenerNode node, ReflectorListener listener, ToolWindowManager wm) {
        if (listener == null) {
            throw new NullPointerException("listener");
        } else if (wm == null) {
            throw new NullPointerException("Tool window manager");
        } else if (node == null) {
            throw new NullPointerException("Listener Node");
        }
        this.wm = wm;
        this.reflectorListener = listener;
        this.node = node;
//        this.listenerId = listenerId;
//        this.reflector = reflector;
        initComponents();
        initBaseConfiguration();
    }

    private void initBaseConfiguration() {
        resetAllFeedBackLabels();
        if (reflectorListener.getPort() != null) {
            portField.setText(reflectorListener.getPort().toString());
        } else {
            portField.setText("");
        }
        if (reflectorListener.getDataSize() != null) {
            dataSizeField.setText(reflectorListener.getDataSize().toString());
        } else {
            dataSizeField.setText("");
        }

        if (reflectorListener.getType() == null) {
            reflectorListener.setType(ReflectorListenerType.udp);
        }
        switch (reflectorListener.getType()) {
            case udp:
                udpButton.doClick();
                resetAllUnvalaibleFields();
                break;
            case tcp:
                tcpButton.doClick();
                resetAllUnvalaibleFields();
                if (reflectorListener.getBindAddress() != null) {
                    bindAddressField.setText(reflectorListener.getBindAddress());
                } else {
                    bindAddressField.setText("");
                }
                break;
            case mcast:
                mcastButton.doClick();
                resetAllUnvalaibleFields();
                if (reflectorListener.getMulticastGroup() != null) {
                    multicastGroupField.setText(reflectorListener.getMulticastGroup());
                } else {
                    multicastGroupField.setText("");
                }
                if (reflectorListener.getDestinationPort() != null) {
                    destinationPortField.setText(reflectorListener.getDestinationPort().toString());
                } else {
                    destinationPortField.setText("");
                }
                if (reflectorListener.getTimeToLive() != null) {
                    ttlField.setText(reflectorListener.getTimeToLive().toString());
                } else {
                    ttlField.setText("");
                }
                break;
            default:
                throw new IllegalStateException("This Listener Type isn't provided.");
        }

    }

    @Action
    @Override
    public void saveAction() {
        if (isSaved()) {
            return;
        }
        resetAllFeedBackLabels();
        Integer intPort = FieldValidator.getInstance().controlAndParsePortInteger(portFeedBackLabal, "Port", portField.getText(), true);
        Long longDataSize = FieldValidator.getInstance().controlAndParseDataSizeInteger(dataSizeFeedBackLabel, "Size", dataSizeField.getText(), false);
        if (intPort != null) {
            try {
                createStopRequest();
            } catch (SenderException ex) {
                //TODO zachytit nenajiti klice a vyhodit nejakej dialog at si to spravi v tom properties souboru
                Logger.getLogger(ListenerCreatorPane.class.getName()).log(Level.SEVERE, null, ex);
            }
            reflectorListener.setPort(intPort);
            reflectorListener.setDataSize(longDataSize);
            if (udpButton.isSelected()) {
                reflectorListener.setType(ReflectorListener.ReflectorListenerType.udp);
            } else if (tcpButton.isSelected()) {
                reflectorListener.setType(ReflectorListener.ReflectorListenerType.tcp);
                reflectorListener.setBindAddress(bindAddressField.getText());
            } else if (mcastButton.isSelected()) {
                Integer intDestPort = FieldValidator.getInstance().controlAndParsePortInteger(destinationPortFeedBackLabel, "Destination Port", destinationPortField.getText(), false);
                reflectorListener.setType(ReflectorListener.ReflectorListenerType.mcast);
                reflectorListener.setMulticastGroup(multicastGroupField.getText());
                reflectorListener.setDestinationPort(intDestPort);
//                reflectorListener.setTimeToLive();
//                ttlField.setText("");
                //TODO ---ListenerCreator--- urychlene dodelat neuklada se TTL
            }
            actualizeName();
            try {
                createStartRequests();
            } catch (SenderException ex) {
                //TODO zachytit nenajiti klice a vyhodit nejakej dialog at si to spravi v tom properties souboru
                Logger.getLogger(ListenerCreatorPane.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    private void createStopRequest() throws SenderException {
        if (reflectorListener.getType() == null | reflectorListener.getPort() == null) {
            return;
        }
        Factory.getSenderManager().addRequest("Method.stop.listener", reflectorListener.getAllParams());
    }

    private void createStartRequests() throws SenderException {
        ReflectorSession session = ModelPane.getInstance().getPresentReflector().getReflectorSessionByReflectorListener(reflectorListener);
        Factory.getSenderManager().addRequest("Method.start.listener", reflectorListener.getAllParams());
        //TODO Poslat rapRequest
        if (session.size() != 1) {
            Factory.getSenderManager().addRequest("Method.connect.session", session.getAllParams());
        }
    }

    private boolean isSavedPortAndDataSize() {
        //overeni ulozeni portu
        if ("".equals(portField.getText())) {
            return false;
        }
        try {
            if (!reflectorListener.getPort().equals(Integer.valueOf(portField.getText()))) {
                return false;
            }
        } catch (NumberFormatException ne) {
            return false;
        }
        //overeni ulozeni dataSize
        if (reflectorListener.getDataSize() == null) {
            return "".equals(dataSizeField.getText());
        } else {
            if ("".equals(dataSizeField.getText())) {
                return false;
            }
            try {
                if (!reflectorListener.getDataSize().equals(Long.valueOf(dataSizeField.getText()))) {
                    return false;
                }

            } catch (NumberFormatException ne) {
                return false;
            }
            return true;
        }
    }

    private boolean isSavedDestinationPort() {
        if (reflectorListener.getDestinationPort() == null) {
            return "".equals(destinationPortField.getText());
        } else {
            try {
                return reflectorListener.getDestinationPort().equals(Integer.valueOf(destinationPortField.getText()));
            } catch (NumberFormatException ne) {
                return false;
            }
        }
    }

    private boolean isSavedMulticastGroup() {
        if (reflectorListener.getMulticastGroup() == null) {
            return "".equals(multicastGroupField.getText());
        } else {
            return reflectorListener.getMulticastGroup().equals(multicastGroupField.getText());
        }
    }

    private boolean isSavedTimeToLive() {
        if (reflectorListener.getTimeToLive() == null) {
            return "".equals(ttlField.getText());
        } else {
            try {
                return reflectorListener.getTimeToLive().equals(Short.valueOf(ttlField.getText()));
            } catch (NumberFormatException ne) {
                return false;
            }
        }
    }

    @Override
    public boolean isSaved() {
        if (reflectorListener.getPort() == null || reflectorListener.getType() == null) {
            return false;
        }
        if (udpButton.isSelected()) {
            if (!ReflectorListener.ReflectorListenerType.udp.equals(reflectorListener.getType())) {
                return false;
            }
            return isSavedPortAndDataSize();
        } else if (tcpButton.isSelected()) {
            if (!ReflectorListener.ReflectorListenerType.tcp.equals(reflectorListener.getType())) {
                return false;
            }
            if (isSavedPortAndDataSize()) {
                if (reflectorListener.getBindAddress() == null) {
                    return "".equals(bindAddressField.getText());
                } else {
                    return reflectorListener.getBindAddress().equals(bindAddressField.getText());
                }
            } else {
                return false;
            }
        } else if (mcastButton.isSelected()) {
            if (!ReflectorListener.ReflectorListenerType.mcast.equals(reflectorListener.getType())) {
                return false;
            }
            if (isSavedPortAndDataSize()) {
                return (isSavedDestinationPort() & isSavedMulticastGroup() & isSavedTimeToLive());
            } else {
                return false;
            }
        } else {
            throw new IllegalStateException("This button isn't provided");
        }
    }

    private void actualizeName() {
        Content content = wm.getContentManager().getContent(node.getId());
        content.setTitle(node.toString());
        wm.getToolWindow(MyDoggyController.MODEL_ID).getComponent().repaint();
    }

    private void resetAllFeedBackLabels() {
        portFeedBackLabal.setText("*");
        dataSizeFeedBackLabel.setText("");
        bindAddressFeedBackLabel.setText("");
        multicastGroupFeedBackLabel.setText("");
        destinationPortFeedBackLabel.setText("");
        ttlFeedBackLabel.setText("");
    }

    @Action
    public void resetAllUnvalaibleFields() {
        if (udpButton.isSelected()) {
            bindAddressField.setText("");
            multicastGroupField.setText("");
            destinationPortField.setText("");
            ttlField.setText("");
        } else if (tcpButton.isSelected()) {
            multicastGroupField.setText("");
            destinationPortField.setText("");
            ttlField.setText("");
        } else if (mcastButton.isSelected()) {
            bindAddressField.setText("");
        }
    }

    @Action
    public void setUDPAction() {
        if (resetFieldCheckBox.isSelected()) {
            resetAllUnvalaibleFields();
        }
        bindAddressLabel.setEnabled(false);
        bindAddressField.setEnabled(false);
        multiCastGroupLabel.setEnabled(false);
        multicastGroupField.setEnabled(false);
        destinationPortLabel.setEnabled(false);
        destinationPortField.setEnabled(false);
        ttlField.setEnabled(false);
        ttlLabel.setEnabled(false);
    }

    @Action
    public void setTCPAction() {
        if (resetFieldCheckBox.isSelected()) {
            resetAllUnvalaibleFields();
        }
        bindAddressLabel.setEnabled(true);
        bindAddressField.setEnabled(true);
        multiCastGroupLabel.setEnabled(false);
        multicastGroupField.setEnabled(false);
        destinationPortLabel.setEnabled(false);
        destinationPortField.setEnabled(false);
        ttlField.setEnabled(false);
        ttlLabel.setEnabled(false);

    }

    @Action
    public void setMCASTAction() {
        if (resetFieldCheckBox.isSelected()) {
            resetAllUnvalaibleFields();
        }
        bindAddressLabel.setEnabled(false);
        bindAddressField.setEnabled(false);
        multiCastGroupLabel.setEnabled(true);
        multicastGroupField.setEnabled(true);
        destinationPortLabel.setEnabled(true);
        destinationPortField.setEnabled(true);
        ttlField.setEnabled(true);
        ttlLabel.setEnabled(true);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        listenerTypeGroup = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        mainListenerPropertiesPane = new javax.swing.JPanel();
        jToolBar1 = new javax.swing.JToolBar();
        udpButton = new javax.swing.JToggleButton();
        tcpButton = new javax.swing.JToggleButton();
        mcastButton = new javax.swing.JToggleButton();
        portLabel = new javax.swing.JLabel();
        dataSizeLabel = new javax.swing.JLabel();
        bindAddressLabel = new javax.swing.JLabel();
        multiCastGroupLabel = new javax.swing.JLabel();
        destinationPortLabel = new javax.swing.JLabel();
        ttlLabel = new javax.swing.JLabel();
        portField = new javax.swing.JTextField();
        dataSizeField = new javax.swing.JTextField();
        bindAddressField = new javax.swing.JTextField();
        multicastGroupField = new javax.swing.JTextField();
        destinationPortField = new javax.swing.JTextField();
        ttlField = new javax.swing.JTextField();
        resetFieldCheckBox = new javax.swing.JCheckBox();
        portFeedBackLabal = new javax.swing.JLabel();
        dataSizeFeedBackLabel = new javax.swing.JLabel();
        bindAddressFeedBackLabel = new javax.swing.JLabel();
        multicastGroupFeedBackLabel = new javax.swing.JLabel();
        destinationPortFeedBackLabel = new javax.swing.JLabel();
        ttlFeedBackLabel = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setName("Form"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        mainListenerPropertiesPane.setName("mainListenerPropertiesPane"); // NOI18N

        jToolBar1.setBorder(null);
        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setName("jToolBar1"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(cz.muni.fi.rum.RumConfigurator.class).getContext().getActionMap(ListenerCreatorPane.class, this);
        udpButton.setAction(actionMap.get("setUDPAction")); // NOI18N
        udpButton.setSelected(true);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(cz.muni.fi.rum.RumConfigurator.class).getContext().getResourceMap(ListenerCreatorPane.class);
        udpButton.setText(resourceMap.getString("udpButton.text")); // NOI18N
        udpButton.setFocusable(false);
        udpButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        udpButton.setMaximumSize(new java.awt.Dimension(51, 21));
        udpButton.setMinimumSize(new java.awt.Dimension(51, 21));
        udpButton.setName("udpButton"); // NOI18N
        udpButton.setPreferredSize(new java.awt.Dimension(51, 21));
        udpButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(udpButton);
        listenerTypeGroup.add(udpButton);

        tcpButton.setAction(actionMap.get("setTCPAction")); // NOI18N
        tcpButton.setText(resourceMap.getString("tcpButton.text")); // NOI18N
        tcpButton.setFocusable(false);
        tcpButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        tcpButton.setMaximumSize(new java.awt.Dimension(51, 21));
        tcpButton.setMinimumSize(new java.awt.Dimension(51, 21));
        tcpButton.setName("tcpButton"); // NOI18N
        tcpButton.setPreferredSize(new java.awt.Dimension(51, 21));
        tcpButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(tcpButton);
        listenerTypeGroup.add(tcpButton);

        mcastButton.setAction(actionMap.get("setMCASTAction")); // NOI18N
        mcastButton.setText(resourceMap.getString("mcastButton.text")); // NOI18N
        mcastButton.setFocusable(false);
        mcastButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        mcastButton.setName("mcastButton"); // NOI18N
        mcastButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(mcastButton);
        listenerTypeGroup.add(mcastButton);

        portLabel.setText(resourceMap.getString("portLabel.text")); // NOI18N
        portLabel.setName("portLabel"); // NOI18N

        dataSizeLabel.setText(resourceMap.getString("dataSizeLabel.text")); // NOI18N
        dataSizeLabel.setName("dataSizeLabel"); // NOI18N

        bindAddressLabel.setText(resourceMap.getString("bindAddressLabel.text")); // NOI18N
        bindAddressLabel.setEnabled(false);
        bindAddressLabel.setName("bindAddressLabel"); // NOI18N

        multiCastGroupLabel.setText(resourceMap.getString("multiCastGroupLabel.text")); // NOI18N
        multiCastGroupLabel.setEnabled(false);
        multiCastGroupLabel.setName("multiCastGroupLabel"); // NOI18N

        destinationPortLabel.setText(resourceMap.getString("destinationPortLabel.text")); // NOI18N
        destinationPortLabel.setEnabled(false);
        destinationPortLabel.setName("destinationPortLabel"); // NOI18N

        ttlLabel.setText(resourceMap.getString("ttlLabel.text")); // NOI18N
        ttlLabel.setEnabled(false);
        ttlLabel.setName("ttlLabel"); // NOI18N

        portField.setName("portField"); // NOI18N

        dataSizeField.setName("dataSizeField"); // NOI18N

        bindAddressField.setEnabled(false);
        bindAddressField.setName("bindAddressField"); // NOI18N

        multicastGroupField.setEnabled(false);
        multicastGroupField.setName("multicastGroupField"); // NOI18N

        destinationPortField.setEnabled(false);
        destinationPortField.setName("destinationPortField"); // NOI18N

        ttlField.setEnabled(false);
        ttlField.setName("ttlField"); // NOI18N

        resetFieldCheckBox.setAction(actionMap.get("resetAllUnvalaibleFields")); // NOI18N
        resetFieldCheckBox.setSelected(true);
        resetFieldCheckBox.setText(resourceMap.getString("resetFieldCheckBox.text")); // NOI18N
        resetFieldCheckBox.setFocusable(false);
        resetFieldCheckBox.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
        resetFieldCheckBox.setName("resetFieldCheckBox"); // NOI18N
        resetFieldCheckBox.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        portFeedBackLabal.setText(resourceMap.getString("portFeedBackLabal.text")); // NOI18N
        portFeedBackLabal.setName("portFeedBackLabal"); // NOI18N

        dataSizeFeedBackLabel.setName("dataSizeFeedBackLabel"); // NOI18N

        bindAddressFeedBackLabel.setName("bindAddressFeedBackLabel"); // NOI18N

        multicastGroupFeedBackLabel.setName("multicastGroupFeedBackLabel"); // NOI18N

        destinationPortFeedBackLabel.setName("destinationPortFeedBackLabel"); // NOI18N

        ttlFeedBackLabel.setName("ttlFeedBackLabel"); // NOI18N

        jButton1.setAction(actionMap.get("saveAction")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N

        javax.swing.GroupLayout mainListenerPropertiesPaneLayout = new javax.swing.GroupLayout(mainListenerPropertiesPane);
        mainListenerPropertiesPane.setLayout(mainListenerPropertiesPaneLayout);
        mainListenerPropertiesPaneLayout.setHorizontalGroup(
            mainListenerPropertiesPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainListenerPropertiesPaneLayout.createSequentialGroup()
                .addGroup(mainListenerPropertiesPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 329, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(mainListenerPropertiesPaneLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(resetFieldCheckBox))
                    .addGroup(mainListenerPropertiesPaneLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(mainListenerPropertiesPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(bindAddressLabel)
                            .addComponent(multiCastGroupLabel)
                            .addComponent(ttlLabel)
                            .addComponent(destinationPortLabel)
                            .addComponent(jButton1)
                            .addComponent(portLabel)
                            .addComponent(dataSizeLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(mainListenerPropertiesPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(bindAddressField, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)
                            .addComponent(ttlField)
                            .addComponent(destinationPortField)
                            .addComponent(multicastGroupField, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)
                            .addComponent(dataSizeField)
                            .addComponent(portField, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(mainListenerPropertiesPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(portFeedBackLabal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(dataSizeFeedBackLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                            .addComponent(bindAddressFeedBackLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                            .addComponent(multicastGroupFeedBackLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                            .addComponent(destinationPortFeedBackLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                            .addComponent(ttlFeedBackLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        mainListenerPropertiesPaneLayout.setVerticalGroup(
            mainListenerPropertiesPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainListenerPropertiesPaneLayout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(resetFieldCheckBox)
                .addGap(27, 27, 27)
                .addGroup(mainListenerPropertiesPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(portField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(portLabel)
                    .addComponent(portFeedBackLabal))
                .addGap(5, 5, 5)
                .addGroup(mainListenerPropertiesPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainListenerPropertiesPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(dataSizeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(dataSizeLabel))
                    .addComponent(dataSizeFeedBackLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainListenerPropertiesPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bindAddressLabel)
                    .addComponent(bindAddressFeedBackLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(bindAddressField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainListenerPropertiesPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(multicastGroupField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(multiCastGroupLabel)
                    .addComponent(multicastGroupFeedBackLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainListenerPropertiesPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(destinationPortField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(destinationPortLabel)
                    .addComponent(destinationPortFeedBackLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainListenerPropertiesPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainListenerPropertiesPaneLayout.createSequentialGroup()
                        .addGroup(mainListenerPropertiesPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(ttlField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ttlLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton1))
                    .addComponent(ttlFeedBackLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jScrollPane1.setViewportView(mainListenerPropertiesPane);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel bindAddressFeedBackLabel;
    private javax.swing.JTextField bindAddressField;
    private javax.swing.JLabel bindAddressLabel;
    private javax.swing.JLabel dataSizeFeedBackLabel;
    private javax.swing.JTextField dataSizeField;
    private javax.swing.JLabel dataSizeLabel;
    private javax.swing.JLabel destinationPortFeedBackLabel;
    private javax.swing.JTextField destinationPortField;
    private javax.swing.JLabel destinationPortLabel;
    private javax.swing.JButton jButton1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.ButtonGroup listenerTypeGroup;
    private javax.swing.JPanel mainListenerPropertiesPane;
    private javax.swing.JToggleButton mcastButton;
    private javax.swing.JLabel multiCastGroupLabel;
    private javax.swing.JLabel multicastGroupFeedBackLabel;
    private javax.swing.JTextField multicastGroupField;
    private javax.swing.JLabel portFeedBackLabal;
    private javax.swing.JTextField portField;
    private javax.swing.JLabel portLabel;
    private javax.swing.JCheckBox resetFieldCheckBox;
    private javax.swing.JToggleButton tcpButton;
    private javax.swing.JLabel ttlFeedBackLabel;
    private javax.swing.JTextField ttlField;
    private javax.swing.JLabel ttlLabel;
    private javax.swing.JToggleButton udpButton;
    // End of variables declaration//GEN-END:variables
}
